﻿using System.Collections.Generic;
using System.Data;
using MaLu.Data;

namespace MaLu.BusiLogic
{
    public class BLPoverty
    {
       public static DataSet GetAllowanceByYearAndVillage(IDbProvider provider, int year, string village)
       {
           List<IDataParameter> paraList = new List<IDataParameter>();
           paraList.Add(SqlHelper.Instance.CreateParameter("@Year", DataType.Int32,8, year));
           paraList.Add(SqlHelper.Instance.CreateParameter("@Villiage", DataType.VarChar, 10, village));
           DataSet ds = SqlHelper.Instance.ExecuteProcedure(provider, "Proc_SGetMoneyByVilliage", paraList.ToArray());
           return ds;
       }


       public static DataTable GetMoneyDetailByVillageIDAndYear(IDbProvider provider, int year,string  village)
       {

           List<IDataParameter> paraList = new List<IDataParameter>();
           paraList.Add(SqlHelper.Instance.CreateParameter("@Year", DataType.Int32, 8, year));
           paraList.Add(SqlHelper.Instance.CreateParameter("@Village", DataType.VarChar, 10, village));
           DataSet ds = SqlHelper.Instance.ExecuteProcedure(provider, "Proc_SGetMoneyDetailByVillageIDAndYear", paraList.ToArray());
           return ds.Tables[0];
       }
       public static DataSet SumLiving(IDbProvider provider, int year, string village ,int halfyear,string  type)
       {

           List<IDataParameter> paraList = new List<IDataParameter>();
           paraList.Add(SqlHelper.Instance.CreateParameter("@Year", DataType.Int32, 8, year));
           paraList.Add(SqlHelper.Instance.CreateParameter("@Village", DataType.VarChar, 10, village));

           paraList.Add(SqlHelper.Instance.CreateParameter("@Type", DataType.VarChar, 4, type));
           paraList.Add(SqlHelper.Instance.CreateParameter("@HalfYear", DataType.Int32, 8, halfyear));
           DataSet ds = SqlHelper.Instance.ExecuteProcedure(provider, "Proc_SGetLive", paraList.ToArray());
           return ds;
       }
       public static DataSet SumStudy(IDbProvider provider, int year, string village, int halfyear)
       {

           List<IDataParameter> paraList = new List<IDataParameter>();
           paraList.Add(SqlHelper.Instance.CreateParameter("@Year", DataType.Int32, 8, year));
           paraList.Add(SqlHelper.Instance.CreateParameter("@Village", DataType.VarChar, 10, village));

           paraList.Add(SqlHelper.Instance.CreateParameter("@HalfYear", DataType.Int32, 8, halfyear));
           DataSet ds = SqlHelper.Instance.ExecuteProcedure(provider, "Proc_SGetStudy", paraList.ToArray());
           return ds;
       }

        
       public static DataSet SumSick(IDbProvider provider, int year, string village, int month)
       {

           List<IDataParameter> paraList = new List<IDataParameter>();
           paraList.Add(SqlHelper.Instance.CreateParameter("@Year", DataType.Int32, 8, year));
           paraList.Add(SqlHelper.Instance.CreateParameter("@Village", DataType.VarChar, 10, village));
           paraList.Add(SqlHelper.Instance.CreateParameter("@Month", DataType.Int32, 8, month));
           DataSet ds = SqlHelper.Instance.ExecuteProcedure(provider, "Proc_SGetSick", paraList.ToArray());
           return ds;
       }

       public static DataSet SumDeformity(IDbProvider provider, int year, string village, int month, string type)
       {

           List<IDataParameter> paraList = new List<IDataParameter>();
           paraList.Add(SqlHelper.Instance.CreateParameter("@Year", DataType.Int32, 8, year));
           paraList.Add(SqlHelper.Instance.CreateParameter("@Village", DataType.VarChar, 10, village));

           paraList.Add(SqlHelper.Instance.CreateParameter("@Type", DataType.VarChar, 4, type));
           paraList.Add(SqlHelper.Instance.CreateParameter("@Month", DataType.Int32, 8, month));
           DataSet ds = SqlHelper.Instance.ExecuteProcedure(provider, "Proc_SGetDeformity", paraList.ToArray());
           return ds;
       }
       public static DataSet SumOther(IDbProvider provider, int year, string village, int month)
       {

           List<IDataParameter> paraList = new List<IDataParameter>();
           paraList.Add(SqlHelper.Instance.CreateParameter("@Year", DataType.Int32, 8, year));
           paraList.Add(SqlHelper.Instance.CreateParameter("@Village", DataType.VarChar, 10, village));
           paraList.Add(SqlHelper.Instance.CreateParameter("@Month", DataType.Int32, 8, month));
           DataSet ds = SqlHelper.Instance.ExecuteProcedure(provider, "Proc_SGetOther", paraList.ToArray());
           return ds;
       }

       public static DataTable GetPType()
       {
           DataTable dt = new DataTable();
           dt.Columns.Add("value");
           dt.Columns.Add("text");

           string[] values = new string[] { "sliving", "ssick", "sstudy", "sdeformity", "sothers" };
           string[] texts = new string[] { "低保", "大病扶持", "助学救助", "重残无业", "其他救助" };
           int length = values.Length;
           for (int i = 0; i < length; i++)
           {
               DataRow dr = dt.NewRow();
               dr["value"] = values[i];
               dr["text"] = texts[i];
               dt.Rows.Add(dr);
           }

           return dt;

       }
       public static DataTable GetFType(IDbProvider provider)
       {
           return SqlHelper.Instance.ExecuteDataTable(provider, "select * from PDicVillages");
       }
       public static string GetName(string type)
       {
           type = type.ToLower();
           string name=string.Empty;
           if (type == "slivet")
               name = "城镇低保" ;
           if (type == "slivev")
               name = "农村低保";
           if (type == "ssick")
               name = "大病扶持";
           if (type == "sstudy")
               name = "助学救助";
           if (type == "sdeformityt")
               name = "城镇重残无业";
           if (type == "sdeformityv")
               name = "农村重残无业";
           if (type == "sothers")
               name = "其他救助";
           return name;
       
       }
    } 
}
